package org.zhao.nettydemos.mythread;

import java.util.concurrent.TimeUnit;

/**
 * @Auther: xiaohui.zhao
 * @Date: 2021/9/17 14:06
 * @Description:  县城不断休眠
 *
 * 在循环中调用TimeUnit.SECONDS.sleep(long) 来验证线程的TIMED_WAITING状态
 *
 */
public class WaitingTime implements Runnable{
    @Override
    public void run() {
        while(true){
            waitSeconds(200);
        }
    }

    /**
     * 线程等待多少秒
     * @param seconds  毫秒
     */
    public static final void waitSeconds(long seconds){
        try{
            TimeUnit.SECONDS.sleep(seconds);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}